package com.lxmes.pm.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.lxmes.common.annotation.Log;
import com.lxmes.common.core.controller.BaseController;
import com.lxmes.common.core.domain.AjaxResult;
import com.lxmes.common.enums.BusinessType;
import com.lxmes.pm.domain.AOutlayProject;
import com.lxmes.pm.service.IAOutlayProjectService;
import com.lxmes.common.utils.poi.ExcelUtil;
import com.lxmes.common.core.page.TableDataInfo;

/**
 * 经费科目管理Controller
 * 
 * @author zhangzhiyu
 * @date 2023-04-04
 */
@RestController
@RequestMapping("/pm/outlayProject")
public class AOutlayProjectController extends BaseController
{
    @Autowired
    private IAOutlayProjectService aOutlayProjectService;

    /**
     * 查询经费科目管理列表
     */
    @PreAuthorize("@ss.hasPermi('pm:outlayProject:list')")
    @GetMapping("/list")
    public TableDataInfo list(AOutlayProject aOutlayProject)
    {
        startPage();
        List<AOutlayProject> list = aOutlayProjectService.selectAOutlayProjectList(aOutlayProject);
        return getDataTable(list);
    }

    /**
     * 导出经费科目管理列表
     */
    @PreAuthorize("@ss.hasPermi('pm:outlayProject:export')")
    @Log(title = "经费科目管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, AOutlayProject aOutlayProject)
    {
        List<AOutlayProject> list = aOutlayProjectService.selectAOutlayProjectList(aOutlayProject);
        ExcelUtil<AOutlayProject> util = new ExcelUtil<AOutlayProject>(AOutlayProject.class);
        util.exportExcel(response, list, "经费科目管理数据");
    }

    /**
     * 获取经费科目管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('pm:outlayProject:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(aOutlayProjectService.selectAOutlayProjectById(id));
    }

    /**
     * 新增经费科目管理
     */
    @PreAuthorize("@ss.hasPermi('pm:outlayProject:add')")
    @Log(title = "经费科目管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody AOutlayProject aOutlayProject)
    {
        return toAjax(aOutlayProjectService.insertAOutlayProject(aOutlayProject));
    }

    /**
     * 修改经费科目管理
     */
    @PreAuthorize("@ss.hasPermi('pm:outlayProject:edit')")
    @Log(title = "经费科目管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody AOutlayProject aOutlayProject)
    {
        return toAjax(aOutlayProjectService.updateAOutlayProject(aOutlayProject));
    }

    /**
     * 删除经费科目管理
     */
    @PreAuthorize("@ss.hasPermi('pm:outlayProject:remove')")
    @Log(title = "经费科目管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(aOutlayProjectService.deleteAOutlayProjectByIds(ids));
    }
}
